package com.zsule.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import com.zsule.entity.Shipping;
import com.zsule.frameworks.mongodb.service.MongoAbstractService;
import com.zsule.service.IShoppingService;

@Service("shoppingService")
public class ShoppingServiceImpl extends MongoAbstractService<Shipping> implements IShoppingService{

	@Override
	public List<Shipping> getShippingByUser(String userId) {
		Query query = new Query(Criteria.where("userId").is(userId));
		List<Order> orders = new ArrayList<Order>();
		orders.add(new Order(Direction.DESC, "range"));
		query.with(new Sort(orders));
		return findList(query);
	}
}
